package com.itheima.dao.impl;

import com.itheima.dao.BookDao;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * TODO:bean基本注解配置
 *
 * 1.添加到IOC容器中
 *      @Component           @Controller  @Service   @Repository
 *      组件 （三层以外）          web         service     dao
 * 2、Scope 作用范围
 *      singleton
 *      prototype
 *
 * 3、生命周期
 * @PostConstruct   初始化方法
 * @PreDestory      销毁方法
 */
@Repository("bookDao")
@Scope("prototype")
public class BookDaoImpl implements BookDao {
    @Override
    public void save() {
        System.out.println("BookDaoImpl run...");
    }

    @PostConstruct
    public void init(){
        System.out.println("BookDaoImpl init....");
    }

    @PreDestroy
    public void destory(){
        System.out.println("BookDaoImpl destory....");
    }
}
